/**
 * 
 */
package com.wegax.finprod;

import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.HorizontalLayout;
import com.wegax.finprod.accountcard.PersonalAccountDebitCardView;
import com.wegax.finprod.message.MessageCodes;
import com.wegax.finprod.message.Messages;

/**
 * @author wegax
 * 
 */
class ApplicationFormsSelectionView extends HorizontalLayout implements ApplicationFormsController, TitledForm {

	private final MainViewChanger mainViewChanger;

	public ApplicationFormsSelectionView(MainViewChanger mainViewChanger) {
		this.mainViewChanger = mainViewChanger;
		initComponents();
	}

	private void initComponents() {
		Button personalAccountDebitCardV1Button = new Button(
				Messages.getString(MessageCodes.PERSONAL_ACCOUNT_DEBIT_CARD_APPLICATION_FORM_TITLE));
		personalAccountDebitCardV1Button.addListener(new Button.ClickListener() {

			@Override
			public void buttonClick(ClickEvent event) {
				mainViewChanger.changeView(new PersonalAccountDebitCardView(ApplicationFormsSelectionView.this));
			}
		});

		this.addComponent(personalAccountDebitCardV1Button);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.wegax.finprod.ApplicationFormsController#cancel()
	 */
	@Override
	public void cancel() {
		show();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.wegax.finprod.ApplicationFormsController#afterSend()
	 */
	@Override
	public void afterSend() {
		show();
	}

	private void show() {
		mainViewChanger.changeView(this);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.wegax.finprod.TitledForm#getComponentContainer()
	 */
	@Override
	public ComponentContainer getComponentContainer() {
		return this;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.wegax.finprod.TitledForm#getTitle()
	 */
	@Override
	public String getTitle() {
		return Messages.getString(MessageCodes.APPLICATION_FORM_SELECTION_TITLE);
	}

}
